//
//  PictureScrollViewController.m
//  Share_Home_F
//
//  Created by dllo on 15/4/22.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "PictureScrollViewController.h"
#import "UIImageView+WebCache.h"
#import "PictureModel.h"

#define WIDTH self.view.frame.size.width



@interface PictureScrollViewController ()<UIScrollViewDelegate>
@property (nonatomic, assign)NSInteger index;
@end

@implementation PictureScrollViewController

- (void)dealloc
{
    [super dealloc];
}
-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
      //  self.arr = [NSArray array];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self createScrollView];
    [self createButton];

  
    
}

#pragma mark- 分享按钮
- (void)createButton
{
    UIButton *abutton = [UIButton buttonWithType:UIButtonTypeSystem];
    abutton.frame = CGRectMake(60, 450, 80, 50);
    [abutton setBackgroundColor:[UIColor cyanColor]];
    abutton.layer.borderWidth = 2;
    abutton.layer.cornerRadius =10;
    
    [abutton setTitle:@"分享" forState:UIControlStateNormal];
    [abutton addTarget:self action:@selector(ClickShare:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:abutton];
  
   
    UIButton *bbutton = [UIButton buttonWithType:UIButtonTypeSystem];
    bbutton.frame = CGRectMake(235, 450, 80, 50);
    [bbutton setBackgroundColor:[UIColor cyanColor]];
    bbutton.layer.borderWidth = 2;
    bbutton.layer.cornerRadius =10;
    
    [bbutton setTitle:@"收藏" forState:UIControlStateNormal];
    [bbutton addTarget:self action:@selector(ClickCollect:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:bbutton];
    
    
}
#pragma mark- 分享方法
- (void)ClickShare:(id)sender
{
    
    
}
#pragma mark- 收藏方法
- (void)ClickCollect:(id)sender
{
    
}

- (void)createScrollView
{
    self.scrollView =[[UIScrollView alloc] init];
    self.scrollView.frame = CGRectMake(0, 100, WIDTH, 300);
    self.scrollView.contentSize = CGSizeMake(WIDTH * self.arr.count, 0);
    self.scrollView.showsHorizontalScrollIndicator = NO;
    self.scrollView.showsVerticalScrollIndicator = NO;
    [self.view setBackgroundColor:[UIColor blackColor]];
    self.scrollView.pagingEnabled = YES;
    [self.view addSubview:self.scrollView];
  
    [_scrollView release];
    
    for (NSInteger i = 0; i < self.arr.count; i++) {
        NSURL *url = [NSURL URLWithString:[self.arr[i] bimgfile]];
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH * i, 0, WIDTH, 300)];
        [imageView sd_setImageWithURL:url];
        [self.scrollView addSubview:imageView];
       
        
    if ([self.idNum isEqualToString: [self.arr[i] id]]) {
//        NSLog(@"%@", [self.arr[i] id]);
        NSLog(@"%@", self.idNum);
            self.index = i;
        }
    }
    self.scrollView.contentOffset = CGPointMake(WIDTH * (self.index ), 0);
   
}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
   
}



@end
